C MODPATH Version 3.00 (V3, Release 2, 5-99)
C Changes:
C   No change since previous release: (V3, Release 1, 9-94)
C***** SUBROUTINES *****
C     FILHDR
C     WRITEP
C     WRITTS
C     WRITPL
C***********************
 
C***** SUBROUTINE *****
      SUBROUTINE FILHDR(IU,VER,ICMPCT,TREF)
      CHARACTER*(*) VER
      CHARACTER*10 STYLE
      CHARACTER*4 LEFT
      CHARACTER*2 RIGHT
      CHARACTER*80 LINE  ! emrl 80 to 256
C
      LINE=VER
      LEFT= '@ [ '
      RIGHT= ' ]'
      IF(ICMPCT.LT.2) THEN
        IF(ICMPCT.EQ.1) THEN
          STYLE= '(COMPACT)'
          CALL CHOP(STYLE,LS)
        ELSE
          LS=1
          STYLE= ' '
        END IF
        CALL CHOP(VER,LV)
        REWIND(IU)
        WRITE(IU,1000) LEFT,VER(1:LV),STYLE(1:LS),TREF,RIGHT
1000    FORMAT(A4,A,A,'(TREF=',E15.6,' )',A2)
 
      ELSE IF(ICMPCT.EQ.2) THEN
        REWIND(IU)
        WRITE(IU) LINE,TREF
      END IF
 
      RETURN
      END
 
C***** SUBROUTINE *****
      SUBROUTINE WRITEP(IU,ICMPCT,IZONE,J,I,K,X,Y,ZL,Z,TOT,XSTRT,
     1 YSTRT,ZLSTRT,JFRST,IFRST,KFRST,IZONE2,NSFRST,IPCODE,TRLEAS,
     2 NROW,NCOL)
C
      IF(ICMPCT.EQ.1) THEN
        ND= (K-1)*NROW*NCOL + (I-1)*NCOL + J
        NDFRST= (KFRST-1)*NROW*NCOL + (IFRST-1)*NCOL + JFRST
        WRITE(IU,1000) IZONE,ND,X,Y,ZL,TOT,XSTRT,YSTRT,ZLSTRT,
     1                 NDFRST,IZONE2,NSFRST,IPCODE,TRLEAS
1000    FORMAT(I3,1X,I6,1X,1PE12.5,6(1X,E12.5),1X,I6,1X,I3,1X,I5,1X,I6,
     1         1X,E12.5)
 
      ELSE IF(ICMPCT.EQ.2) THEN
        ND= (K-1)*NROW*NCOL + (I-1)*NCOL + J
        NDFRST= (KFRST-1)*NROW*NCOL + (IFRST-1)*NCOL + JFRST
        WRITE(IU) IZONE,ND,X,Y,ZL,TOT,XSTRT,YSTRT,ZLSTRT,
     1                 NDFRST,IZONE2,NSFRST,IPCODE,TRLEAS
 
 
      ELSE
        WRITE(IU,2000) IZONE,J,I,K,X,Y,Z,ZL,TOT,XSTRT,YSTRT,ZLSTRT,
     1     JFRST,IFRST,KFRST,IZONE2,NSFRST,IPCODE,TRLEAS
2000    FORMAT(I3,3(1X,I4),1X,1PE12.5,7(1X,E12.5),3(1X,I4),1X,I3,1X,I5,
     1    1X,I6,1X,E12.5)
      END IF
 
      RETURN
      END
 
C***** SUBROUTINE *****
      SUBROUTINE WRITTS(IU,ICMPCT,MPSTP,NP,J,I,K,X,Y,Z,ZL,T,NSTEP,
     1                  NROW,NCOL)
C
      IF(ICMPCT.EQ.1) THEN
        ND= (K-1)*NROW*NCOL + (I-1)*NCOL + J
        WRITE(IU,1000) MPSTP,NP,ND,X,Y,Z,ZL,T,NSTEP
1000    FORMAT(I4,2(1X,I7),1X,1PE12.5,4(1X,E12.5),1X,I7)
 
      ELSE IF(ICMPCT.EQ.2) THEN
        ND= (K-1)*NROW*NCOL + (I-1)*NCOL + J
        WRITE(IU) MPSTP,NP,ND,X,Y,Z,ZL,T,NSTEP
 
      ELSE
        WRITE(IU,2000) MPSTP,NP,J,I,K,X,Y,Z,ZL,T,NSTEP
2000    FORMAT(I4,1X,I7,3(1X,I4),1X,1PE12.5,4(1X,E12.5),1X,I7)
      END IF
 
      RETURN
      END
 
C***** SUBROUTINE *****
      SUBROUTINE WRITPL(IU,ICMPCT,IP,X,Y,ZL,Z,T,J,I,K,NSTEP,NROW,NCOL)
c
      IF(ICMPCT.EQ.1) THEN
        ND= (K-1)*NROW*NCOL + (I-1)*NCOL + J
        WRITE(IU,1000) IP,X,Y,ZL,Z,T,ND,NSTEP
1000    FORMAT(I7,1X,1PE12.5,4(1X,E12.5),2(1X,I7))
 
      ELSE IF(ICMPCT.EQ.2) THEN
        ND= (K-1)*NROW*NCOL + (I-1)*NCOL + J
        WRITE(IU) IP,X,Y,ZL,Z,T,ND,NSTEP
 
      ELSE
        WRITE(IU,2000) IP,X,Y,ZL,Z,T,J,I,K,NSTEP
2000    FORMAT(I7,1X,1PE12.5,4(1X,E12.5),3(1X,I4),1X,I7)
      END IF
 
      RETURN
      END
